<%@ page language="java" import="java.util.*,entity.*,dao.*,dao.impl.*,biz.*,biz.impl.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
	request.setCharacterEncoding("GBK");
	String title = request.getParameter("title");//取得帖子标题
	String content = request.getParameter("content");//取得帖子内容
	
	int boardId = Integer.parseInt(request.getParameter("boardId"));//取得板块ID
	int topicId = Integer.parseInt(request.getParameter("topicId"));//取得主题ID
	
	User user = (User)session.getAttribute("user");//从session中取得登录用户
	/* int topicId=1;//主题ID固定 */
	/*ReplyDao replyDao = new ReplyDaoImpl();//取得主题Dao的实例*/
	
	ReplyBiz replyBiz = new ReplyBizImpl();
	
	if(user!=null){//判断用户是否已经登录
		Reply reply = new Reply();
		reply.setTitle(title);
		reply.setContent(content);
		reply.setTopicId(topicId);
		reply.setUserId(user.getUserId());
		//发表时间和修改时间将由Dao类生成
		replyBiz.addReply(reply);//保存帖子
		response.sendRedirect("../detail.jsp?page=1&boardId=" + boardId + "&topicId" + topicId);//跳转
		return;
	}else{
		response.sendRedirect("../login.jsp");//转到登录界面
	}
	
/* 	Reply reply = new Reply();
	reply.setTitle(title);
	reply.setContent(content);
	reply.setTopicId(topicId);
	reply.setUserId(1);//用户固定
	
	//发表时间和修改时间将由Dao类生成
	
	replyDao.addReply(reply);//保存帖子
	response.sendRedirect("../detail.jsp");//跳转 */
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>doReply</title>
  </head>
  <body>
  </body>
</html>
